home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr20
/
grr102.zip
/
GRR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-02-24
|
4KB
|
148 lines
PROGRAM displayGIFheader; {$i-} { see GRR.DOC for revision history }
USES dos;
procedure showhelp(const problem :byte);
(* If any *foreseen* errors arise, we are sent here to
give a little help and exit (relatively) peacefully *)
const
progdesc = 'GRR v1.02 - Free DOS utility: GIF file information displayer.';
author = 'February 24, 1995. Copyright (c) 1995 by David Daniel Anderson - Reign Ware.';
usage = 'Usage: GRR [file_spec] Example: GRR a:\mariah*.gif';
var
message : string[50];
begin
writeln(progdesc);
writeln(author); writeln;
writeln(usage); writeln;
if problem > 0 then begin
case problem of
1 : message := 'No files matching specification found.';
else message := 'Unanticipated error of unknown type.';
end;
writeln (#7,message);
end;
halt(problem)
end;
FUNCTION leadingzero (w :word) : STRING;
VAR
s : STRING;
BEGIN
str (w :0, s);
IF (length (s) = 1) THEN
s:='0'+s;
leadingzero:=s;
END;
FUNCTION Comma (li :longint) : STRING;
VAR s : STRING[15];
l : ShortInt;
BEGIN
Str (li, s);
l:=(Length (s)-2);
WHILE (l > 1) DO BEGIN
Insert (',', s, l);
Dec (l, 3);
END;
Comma:=s;
END;
Function RPad(bstr: string; Const len: byte): string;
Begin
while (length(bstr) < len) do
bstr := bstr + #32;
RPad := bstr;
End;
PROCEDURE getpath (VAR new_path :pathstr);
BEGIN
IF (paramstr (1) = '') THEN
new_path:='*.gif'
ELSE BEGIN
new_path:=paramstr (1);
IF (pos ('.', new_path) = 0) THEN
new_path:=new_path+'*.gif';
END;
END;
PROCEDURE writetime (fdatetime :longint);
VAR
DateTimeInf : DateTime;
BEGIN
UnpackTime (fdatetime, DateTimeInf);
WITH DateTimeInf DO BEGIN
Write
(LeadingZero (Month):4,'-', LeadingZero (Day) ,'-',
Copy(LeadingZero(Year),3,2), ' ',
LeadingZero (Hour) ,':', LeadingZero (Min) ,':', LeadingZero (Sec));
END;
END;
PROCEDURE checkforgiflite (VAR thefile :FILE; const offset: word);
CONST
giflite: array[1..7] of char = #32#32#32#32#32#32#32;
blocklabel: array[1..2] of char = #32#32;
BEGIN
seek (thefile, filepos(thefile) + 2 + (3*offset));
blockread (thefile, blocklabel, 2);
if blocklabel = #33#255 then begin
seek (thefile, filepos(thefile) + 1);
blockread (thefile, giflite, 7);
end;
IF (giflite = 'GIFLITE')
THEN writeln ('GL')
ELSE writeln ('--');
END;
TYPE
gif_header=RECORD
gif_version : ARRAY[1..6] OF char;
width,
height : word;
resolution : byte; { The next byte is "background", but I }
END; { don't want to report it at this time. }
VAR
header: gif_header;
gpath: pathstr; gdir: dirstr; gname: namestr; gext: extstr;
dirinfo: searchrec;
giffile: file;
numfiles: word; sizefiles: longint;
BytesRead: integer;
maxcolors: word;
BEGIN
numfiles:=0;
sizefiles:=0;
getpath (gpath);
fsplit (fexpand (gpath), gdir, gname, gext);
findfirst (gpath, hidden+archive, dirinfo);
IF (doserror <> 0) THEN showhelp(1);
WHILE (doserror = 0) DO BEGIN
assign (giffile, gdir+dirinfo.name);
reset (giffile, 1);
IF (IOResult = 0) THEN BEGIN
write ((RPad (dirinfo.name, 12)), dirinfo.size :9);
inc(numfiles,1); inc(sizefiles,dirinfo.size);
writetime (dirinfo.time);
blockread (giffile, header, sizeof (header));
IF (IOResult = 0) and (pos ('GIF' , header.gif_version) = 1) THEN
WITH header DO BEGIN
maxcolors := (2 SHL (resolution AND 7)); {formula from SWAG}
write (gif_version :10, ' [', width :4, height :5,
(maxcolors) :5, ' ] ');
IF (resolution > 128) THEN write ('GCM/')
ELSE write ('LCM/');
checkforgiflite (giffile,maxcolors);
END
ELSE writeln(' Unrecognized format - skipping.');
close (giffile);
END;
findnext (dirinfo);
END;
writeln;
Writeln('Interrogated ',numfiles,' files totalling ',comma(sizefiles),' bytes.');
END.